package com.lizhen.core.datastructure;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ArrayListDataStructure {
    public static void main(String[] args) {
        List<String> list = new ArrayList<>();
        list.add("Hello");
        list.add("World");
        list.add("HAHAHAHA");

        String[] arr = new String[list.size()];
        list.toArray(arr);

        Iterator<String> iterator = list.iterator();

        for (String str : list) {
            System.out.println(str);
        }
        for (int i = 0; i < arr.length; i++) {
            System.out.println(arr[i]);
        }
        while (iterator.hasNext()) {
            System.out.println(iterator.next());
        }
    }
}
